package cc.vv.btpartyjob.jnimodule.server

import cc.vv.baselibrary.util.UserInfoManageUtil
import cc.vv.btpartyjob.jnimodule.enums.RoleType

/**
 * 用户角色Server
 * Created by Chen.qi on 2018/10/24.
 */
object UserRoleServer {
    /**
     * 区管理员
     */
    fun getAreaRole(): Boolean {
        var isAdmin = false
        val userRole = UserInfoManageUtil.getUserInfo()?.userRole
        if (null != userRole && userRole.size > 0) {
            for (i in 0 until userRole.size) {
                if (RoleType.AREA_ADMIN.type == userRole[i]?.type) {
                    isAdmin = true
                    break
                }
            }
        }
        return isAdmin
    }

    /**
     * 街道管理员
     */
    fun getStreetRole(): Boolean {
        var isAdmin = false
        val userRole = UserInfoManageUtil.getUserInfo()?.userRole
        if (null != userRole && userRole.size > 0) {
            for (i in 0 until userRole.size) {
                if (RoleType.STREET_ADMIN.type == userRole[i]?.type) {
                    isAdmin = true
                    break
                }
            }
        }
        return isAdmin
    }

    /**
     * 社区管理员
     */
    fun getSheQuRole(): Boolean {
        var isAdmin = false
        val userRole = UserInfoManageUtil.getUserInfo()?.userRole
        if (null != userRole && userRole.size > 0) {
            for (i in 0 until userRole.size) {
                if (RoleType.SECTION_ADMIN.type == userRole[i]?.type) {
                    isAdmin = true
                    break
                }
            }
        }
        return isAdmin
    }

    /**
     * 网格管理员
     */
    fun getGridRole(): Boolean {
        var isAdmin = false
        val userRole = UserInfoManageUtil.getUserInfo()?.userRole
        if (null != userRole && userRole.size > 0) {
            for (i in 0 until userRole.size) {
                if (RoleType.GRID_ADMIN.type == userRole[i]?.type) {
                    isAdmin = true
                    break
                }
            }
        }
        return isAdmin
    }

    /**
     * 单位管理员
     */
    fun getUnitRole(): Boolean {
        var isAdmin = false
        val userRole = UserInfoManageUtil.getUserInfo()?.userRole
        if (null != userRole && userRole.size > 0) {
            for (i in 0 until userRole.size) {
                if (RoleType.UNIT_ADMIN.type == userRole[i]?.type) {
                    isAdmin = true
                    break
                }
            }
        }
        return isAdmin
    }


    /**
     * 是否只是党员
     */
    fun getOnlyPartyRole(): Boolean {
        var isAdmin = false
        val userRole = UserInfoManageUtil.getUserInfo()?.userRole
        if (null != userRole && userRole.size > 0) {
            for (i in 0 until userRole.size) {
                if (RoleType.PARTY_MEMBER.type == userRole[i]?.type) {
                    isAdmin = true
                    break
                }
            }
        }
        return isAdmin
    }


    /**
     * 是否只是四支队伍管理员
     */
    fun getFourTeamsRole(): Boolean {
        var isAdmin = false
        val userRole = UserInfoManageUtil.getUserInfo()?.userRole
        if (null != userRole && userRole.size > 0) {
            for (i in 0 until userRole.size) {
                if (RoleType.TEAM_ADMIN.type == userRole[i]?.type) {
                    isAdmin = true
                    break
                }
            }
        }
        return isAdmin
    }


    /**
     * 是否只是社区大党委管理员
     */
    fun getSheQuDaDangWeiRole(): Boolean {
        var isAdmin = false
        val userRole = UserInfoManageUtil.getUserInfo()?.userRole
        if (null != userRole && userRole.size > 0) {
            for (i in 0 until userRole.size) {
                if (RoleType.SECTION_COMMITTEE_ADMIN.type == userRole[i]?.type) {
                    isAdmin = true
                    break
                }
            }
        }
        return isAdmin
    }

    /**
     * 是否只是单位委管理员
     */
    fun getUnitMangerWeiRole(): Boolean {
        var isAdmin = false
        val userRole = UserInfoManageUtil.getUserInfo()?.userRole
        if (null != userRole && userRole.size > 0) {
            for (i in 0 until userRole.size) {
                if (RoleType.UNIT_ADMIN.type == userRole[i]?.type) {
                    isAdmin = true
                    break
                }
            }
        }
        return isAdmin
    }
}